

using System;
using System.Text;
using ProjectCommon2.Interfaces;

namespace PolePosition.v3.EntityLibrary
{
	// No comments for the class here, all are in Entity.cs.cst
	/// <summary>
	/// </summary>
	/// <remarks></remarks>
	public sealed partial class VendorDistributionPoleEntity
	{		
	#region " Contructors "
		/// <summary>Creates a new (empty) instance of <c>VendorDistributionPoleEntity</c>. Use to create new VendorDistributionPole records.</summary>
		/// <remarks>This constructor just sets up an empty object; it does not contain any initialization code.</remarks>
		public VendorDistributionPoleEntity()
		{
			// do nothing
		}
		/// <summary>Creates a new (empty) instance of <c>VendorDistributionPoleEntity</c>. Use to create new VendorDistributionPole records.</summary>
		/// <param name="enableDefaults">If set to <c>true</c>, it ensures that default values are inserted for every
		/// <c>null</c> property before calculating an Entity's checksum and writing it to the database.
		/// See <see cref="EnableDefaults" /> for more information.</param>
		/// <remarks>Sets up an empty object and only initializes its <see cref="EnableDefaults" /> variable.</remarks>
		public VendorDistributionPoleEntity(bool enableDefaults)
		{
			this.EnableDefaults = enableDefaults;
		}
		/// <summary>Creates a new instance of <c>VendorDistributionPoleEntity</c>. Use when loading VendorDistributionPole records from the database.</summary>
		/// <remarks>Does not perform any work itself. Instead, it calls <see cref="LoadFromDataRow(System.Data.DataRow)" />
		/// to do the work.</remarks>
		/// <param name="dataRowToLoadFrom">Specifies the Data Row from which to obtain values for
		/// <c>VendorDistributionPoleEntity</c>'s construction.</param>
		public VendorDistributionPoleEntity(System.Data.DataRow dataRowToLoadFrom)
		{
			LoadFromDataRow(dataRowToLoadFrom, true);
		}
		/// <summary>Creates a new instance of <c>VendorDistributionPoleEntity</c>. Use when loading VendorDistributionPole records from the database.</summary>
		/// <remarks>Does not perform any work itself. Instead, it calls <see cref="LoadFromDataRow(System.Data.DataRow, bool)" />
		/// to do the work.</remarks>
		/// <param name="dataRowToLoadFrom">Specifies the Data Row from which to obtain values for
		/// <c>VendorDistributionPoleEntity</c>'s construction.</param>
		/// <param name="useCheckSum">Specifies if a checksum test should be performed to verify the integrity of the data.</param>
		public VendorDistributionPoleEntity(System.Data.DataRow dataRowToLoadFrom, bool useCheckSum)
		{
			LoadFromDataRow(dataRowToLoadFrom, useCheckSum);
		}
	#endregion
	
		#region " Methods "

		/// <summary>
		/// Loads the properties of <c>VendorDistributionPoleEntity</c> from the matching columns in the supplied Data Row,
		/// using checksum verification by default.
		/// </summary>
		/// <remarks>No work performed here. Calls <see cref="LoadFromDataRow(System.Data.DataRow, bool)" /> with
		/// <paramref name="useCheckSum" /> set to <c>true</c>.</remarks>
		/// <param name="sourceDataRow">Specifies the Data Row from which to obtain values for
		/// <c>VendorDistributionPoleEntity</c>.</param>
		public void LoadFromDataRow(System.Data.DataRow sourceDataRow)
		{
			LoadFromDataRow(sourceDataRow, true);
		}

		/// <summary>
		/// Loads the properties of <c>VendorDistributionPoleEntity</c> from the matching columns in the supplied Data Row. Provides the option
		/// to enable or disable checksum verification.
		/// </summary>
		/// <param name="sourceDataRow">Specifies the Data Row from which to obtain values for
		/// <c>VendorDistributionPoleEntity</c>.</param>
		/// <param name="useCheckSum">Specifies if a checksum test should be performed to verify the integrity of the data.</param>
		///
		/// <exception cref="ProjectCommon2.Exceptions.MissingDataRowException">Thrown if either the Data Row 
		/// specified in <paramref name="sourceDataRow" /> or its associated table do not exist. The <c>throw</c>
		/// is performed by <see cref="ProjectCommon2.Helpers.ExceptionHelper.Throw(System.Exception)" />, which handles
		/// logging and other activities.</exception>
		///
		/// <exception cref="ProjectCommon2.Exceptions.MissingDataColumnException">Thrown if the Data Row specified in
		/// <paramref name="sourceDataRow" /> is missing one of its columns. The columns it is checked against were determined
		/// when this application was last compiled. The <c>throw</c> is performed by
		/// <see cref="ProjectCommon2.Helpers.ExceptionHelper.Throw(System.Exception)" />, which handles logging and other
		/// related activities.</exception>
		///
		///
		/// <remarks><para>Prior to loading the values from the given Data Row, this method checks that every column relevant to a VendorDistributionPole
		/// record is present in the given Data Row (the columns which should be present are specified in the source table used when building
		/// this file from its template). If there are columns missing, an exception is thrown as specified in the "Exceptions" section. 
		/// If not, it goes through every column in the given Data Row and assigns its value to the matching column property in the Entity, 
		/// except when the value from the database is <c>null</c> (this leaves the property helper object for that column property uninstantiated;
		/// see any of the column properties for more).</para>
		/// <para>After all values are loaded, the <see cref="AcceptChanges()" /> method is called to make each column
		/// property "save" its value and perform other actions that change <c>VendorDistributionPoleEntity</c>'s status. See how the
		/// <c>AcceptChanges()</c> method works for more.</para>
		/// <para><b>Note</b>: There is a variation of this method that verifies the checksum value for tables that contain a checksum
		/// column. That method was generated at compile time only for those Entities that are supposed to deal with such tables.
		/// </para>
		///</remarks>
		public void LoadFromDataRow(System.Data.DataRow sourceDataRow, bool useCheckSum)
		{
			// passed in DataRow must exist
			if (sourceDataRow == null) 
			{
				ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataRowException("VendorDistributionPoleEntityGenBase.LoadFromDataRow() Data Row is null"));
			}
			// passed in DataRow must have associated DataTable
			if (sourceDataRow.Table == null) 
			{
				ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataRowException("VendorDistributionPoleEntityGenBase.LoadFromDataRow() DataRow.Table is null"));
			}
			
			// Vendor_Distribution_Poles_PoleId
				
			if (!sourceDataRow.Table.Columns.Contains("Vendor_Distribution_Poles_PoleId")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("Vendor_Distribution_Poles_PoleId"));}
				
			if (sourceDataRow["Vendor_Distribution_Poles_PoleId"] != System.DBNull.Value)
			{
				this.Vendor_Distribution_Poles_PoleIdObject.Value = (int?)int.Parse(sourceDataRow["Vendor_Distribution_Poles_PoleId"].ToString());
			}
			
			// MapFk
				
			if (!sourceDataRow.Table.Columns.Contains("MapFk")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("MapFk"));}
				
			if (sourceDataRow["MapFk"] != System.DBNull.Value)
			{
				this.MapFkObject.Value = (int?)int.Parse(sourceDataRow["MapFk"].ToString());
			}
			
			// SectionFk
				
			if (!sourceDataRow.Table.Columns.Contains("SectionFk")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("SectionFk"));}
				
			if (sourceDataRow["SectionFk"] != System.DBNull.Value)
			{
				this.SectionFkObject.Value = (int?)int.Parse(sourceDataRow["SectionFk"].ToString());
			}
			
			// SpecieFk
				
			if (!sourceDataRow.Table.Columns.Contains("SpecieFk")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("SpecieFk"));}
				
			if (sourceDataRow["SpecieFk"] != System.DBNull.Value)
			{
				this.SpecieFkObject.Value = (int?)int.Parse(sourceDataRow["SpecieFk"].ToString());
			}
			
			// ClassFK
				
			if (!sourceDataRow.Table.Columns.Contains("ClassFK")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("ClassFK"));}
				
			if (sourceDataRow["ClassFK"] != System.DBNull.Value)
			{
				this.ClassFKObject.Value = (int?)int.Parse(sourceDataRow["ClassFK"].ToString());
			}
			
			// LengthFk
				
			if (!sourceDataRow.Table.Columns.Contains("LengthFk")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("LengthFk"));}
				
			if (sourceDataRow["LengthFk"] != System.DBNull.Value)
			{
				this.LengthFkObject.Value = (int?)int.Parse(sourceDataRow["LengthFk"].ToString());
			}
			
			// TreatmentFk
				
			if (!sourceDataRow.Table.Columns.Contains("TreatmentFk")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("TreatmentFk"));}
				
			if (sourceDataRow["TreatmentFk"] != System.DBNull.Value)
			{
				this.TreatmentFkObject.Value = (int?)int.Parse(sourceDataRow["TreatmentFk"].ToString());
			}
			
			// Latitude
				
			if (!sourceDataRow.Table.Columns.Contains("Latitude")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("Latitude"));}
				
			if (sourceDataRow["Latitude"] != System.DBNull.Value)
			{
				this.LatitudeObject.Value = (decimal?)decimal.Parse(sourceDataRow["Latitude"].ToString());
			}
			
			// Longitude
				
			if (!sourceDataRow.Table.Columns.Contains("Longitude")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("Longitude"));}
				
			if (sourceDataRow["Longitude"] != System.DBNull.Value)
			{
				this.LongitudeObject.Value = (decimal?)decimal.Parse(sourceDataRow["Longitude"].ToString());
			}
			
			// InspBy
				
			if (!sourceDataRow.Table.Columns.Contains("InspBy")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("InspBy"));}
				
			if (sourceDataRow["InspBy"] != System.DBNull.Value)
			{
				this.InspByObject.Value = sourceDataRow["InspBy"].ToString(); 
			}
			
			// Number
				
			if (!sourceDataRow.Table.Columns.Contains("Number")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("Number"));}
				
			if (sourceDataRow["Number"] != System.DBNull.Value)
			{
				this.NumberObject.Value = sourceDataRow["Number"].ToString(); 
			}
			
			// AcquisitionDate
				
			if (!sourceDataRow.Table.Columns.Contains("AcquisitionDate")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("AcquisitionDate"));}
				
			if (sourceDataRow["AcquisitionDate"] != System.DBNull.Value)
			{
				this.AcquisitionDateObject.Value = (DateTime?)DateTime.Parse(sourceDataRow["AcquisitionDate"].ToString());
			}
			
			// Year
				
			if (!sourceDataRow.Table.Columns.Contains("Year")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("Year"));}
				
			if (sourceDataRow["Year"] != System.DBNull.Value)
			{
				this.YearObject.Value = (int?)int.Parse(sourceDataRow["Year"].ToString());
			}
			
			// LVisit
				
			if (!sourceDataRow.Table.Columns.Contains("LVisit")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("LVisit"));}
				
			if (sourceDataRow["LVisit"] != System.DBNull.Value)
			{
				this.LVisitObject.Value = (DateTime?)DateTime.Parse(sourceDataRow["LVisit"].ToString());
			}
			
			// D804
				
			if (!sourceDataRow.Table.Columns.Contains("D804")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("D804"));}
				
			if (sourceDataRow["D804"] != System.DBNull.Value)
			{
				this.D804Object.Value = sourceDataRow["D804"].ToString(); 
			}
			
			// DistributionType
				
			if (!sourceDataRow.Table.Columns.Contains("DistributionType")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("DistributionType"));}
				
			if (sourceDataRow["DistributionType"] != System.DBNull.Value)
			{
				this.DistributionTypeObject.Value = (int?)int.Parse(sourceDataRow["DistributionType"].ToString());
			}
			
			// UserFk
				
			if (!sourceDataRow.Table.Columns.Contains("UserFk")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("UserFk"));}
				
			if (sourceDataRow["UserFk"] != System.DBNull.Value)
			{
				this.UserFkObject.Value = (int?)int.Parse(sourceDataRow["UserFk"].ToString());
			}
			
			// VendorFk
				
			if (!sourceDataRow.Table.Columns.Contains("VendorFk")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("VendorFk"));}
				
			if (sourceDataRow["VendorFk"] != System.DBNull.Value)
			{
				this.VendorFkObject.Value = (int?)int.Parse(sourceDataRow["VendorFk"].ToString());
			}
			
			// InspectorFk
				
			if (!sourceDataRow.Table.Columns.Contains("InspectorFk")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("InspectorFk"));}
				
			if (sourceDataRow["InspectorFk"] != System.DBNull.Value)
			{
				this.InspectorFkObject.Value = (int?)int.Parse(sourceDataRow["InspectorFk"].ToString());
			}
			
			// ProjectFk
				
			if (!sourceDataRow.Table.Columns.Contains("ProjectFk")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("ProjectFk"));}
				
			if (sourceDataRow["ProjectFk"] != System.DBNull.Value)
			{
				this.ProjectFkObject.Value = (int?)int.Parse(sourceDataRow["ProjectFk"].ToString());
			}
			
			// Utility_Asset_Distributions_PoleFk
				
			if (!sourceDataRow.Table.Columns.Contains("Utility_Asset_Distributions_PoleFk")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("Utility_Asset_Distributions_PoleFk"));}
				
			if (sourceDataRow["Utility_Asset_Distributions_PoleFk"] != System.DBNull.Value)
			{
				this.Utility_Asset_Distributions_PoleFkObject.Value = (int?)int.Parse(sourceDataRow["Utility_Asset_Distributions_PoleFk"].ToString());
			}
			
			// GuardsQuantity
				
			if (!sourceDataRow.Table.Columns.Contains("GuardsQuantity")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("GuardsQuantity"));}
				
			if (sourceDataRow["GuardsQuantity"] != System.DBNull.Value)
			{
				this.GuardsQuantityObject.Value = (int?)int.Parse(sourceDataRow["GuardsQuantity"].ToString());
			}
			
			// PoleTag
				
			if (!sourceDataRow.Table.Columns.Contains("PoleTag")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("PoleTag"));}
				
			if (sourceDataRow["PoleTag"] != System.DBNull.Value)
			{
				this.PoleTagObject.Value = (bool?)bool.Parse(sourceDataRow["PoleTag"].ToString());
			}
			
			// GroundWireRepair
				
			if (!sourceDataRow.Table.Columns.Contains("GroundWireRepair")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("GroundWireRepair"));}
				
			if (sourceDataRow["GroundWireRepair"] != System.DBNull.Value)
			{
				this.GroundWireRepairObject.Value = (bool?)bool.Parse(sourceDataRow["GroundWireRepair"].ToString());
			}
			
			// Billable
				
			if (!sourceDataRow.Table.Columns.Contains("Billable")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("Billable"));}
				
			if (sourceDataRow["Billable"] != System.DBNull.Value)
			{
				this.BillableObject.Value = (bool?)bool.Parse(sourceDataRow["Billable"].ToString());
			}
			
			// Kv
				
			if (!sourceDataRow.Table.Columns.Contains("Kv")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("Kv"));}
				
			if (sourceDataRow["Kv"] != System.DBNull.Value)
			{
				this.KvObject.Value = (int?)int.Parse(sourceDataRow["Kv"].ToString());
			}
			
			// Circuit
				
			if (!sourceDataRow.Table.Columns.Contains("Circuit")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("Circuit"));}
				
			if (sourceDataRow["Circuit"] != System.DBNull.Value)
			{
				this.CircuitObject.Value = sourceDataRow["Circuit"].ToString(); 
			}
			
			// ConductorType
				
			if (!sourceDataRow.Table.Columns.Contains("ConductorType")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("ConductorType"));}
				
			if (sourceDataRow["ConductorType"] != System.DBNull.Value)
			{
				this.ConductorTypeObject.Value = (int?)int.Parse(sourceDataRow["ConductorType"].ToString());
			}
			
			// ACSR
				
			if (!sourceDataRow.Table.Columns.Contains("ACSR")) 
				{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("ACSR"));}
				
			if (sourceDataRow["ACSR"] != System.DBNull.Value)
			{
				this.ACSRObject.Value = (int?)int.Parse(sourceDataRow["ACSR"].ToString());
			}
			
			if (!sourceDataRow.Table.Columns.Contains("FriendlyName")) 
			{ProjectCommon2.Helpers.ExceptionHelper.Throw(new ProjectCommon2.Exceptions.MissingDataColumnException("FriendlyName"));}
			this.FriendlyName = sourceDataRow["FriendlyName"].ToString();
			
			
			AcceptChanges();
		}
		
		
		/// <summary>
		/// Makes each column property save its current value, eliminating the possibility to revert to any previous values.
		/// This also has the effect of making the Entity "not dirty".
		/// </summary>
		/// <remarks>
		/// <para>All column properties of an Entity store two separate versions of their values. One version is the most current value, which may be 
		/// modified at will. The other version is the previous value assigned to the property. This makes it possible to revert to that previous value
		/// if and when needed (for more information about how this works, see the documentation for the
		/// <see cref="ProjectCommon2.Helpers.PropertyHelper&lt;PropertyDataType&gt;" /> class).
		/// </para>
		/// <para>When this method is called, it goes through every column property for <c>VendorDistributionPoleEntity</c>
		/// 
		/// and calls their own <c>AcceptChanges()</c> method. This makes the two versions of the property's values equal, which means
		/// that the property cannot revert to a previous value anymore, thus effectively "saving" its value. Also, the Entity's 
		/// <see cref="IsMarkedToDelete" /> property is set to <c>false</c>, and <see cref="IsNew" /> to <c>null</c>. Finally, the 
		/// <see cref="CheckSumOriginal" /> property is set equal to the new <see cref="CheckSum" />.
		/// Besides preserving the Entity's values for a given point in time, these actions also change its status so that it is no longer
		/// "dirty" (see how the <see cref="IsDirty" /> property works).</para>
		/// 
		/// <para>Moreover, when a <c>VendorDistributionPoleEntity</c> is first constructed from values in the database, calling this method is
		/// an acknowledgment that no values are missing from the record from which it was constructed,
		///  and that all values are of the expected type.
		/// </para>
		///</remarks>
		public void AcceptChanges()
		{
			// set is IsMarkedToDelete to false & set originals to current value
			IsMarkedToDelete = false;
			IsNew = null;
			this.Vendor_Distribution_Poles_PoleIdObject.AcceptChanges();
			this.MapFkObject.AcceptChanges();
			this.SectionFkObject.AcceptChanges();
			this.SpecieFkObject.AcceptChanges();
			this.ClassFKObject.AcceptChanges();
			this.LengthFkObject.AcceptChanges();
			this.TreatmentFkObject.AcceptChanges();
			this.LatitudeObject.AcceptChanges();
			this.LongitudeObject.AcceptChanges();
			this.InspByObject.AcceptChanges();
			this.NumberObject.AcceptChanges();
			this.AcquisitionDateObject.AcceptChanges();
			this.YearObject.AcceptChanges();
			this.LVisitObject.AcceptChanges();
			this.D804Object.AcceptChanges();
			this.DistributionTypeObject.AcceptChanges();
			this.UserFkObject.AcceptChanges();
			this.VendorFkObject.AcceptChanges();
			this.InspectorFkObject.AcceptChanges();
			this.ProjectFkObject.AcceptChanges();
			this.Utility_Asset_Distributions_PoleFkObject.AcceptChanges();
			this.GuardsQuantityObject.AcceptChanges();
			this.PoleTagObject.AcceptChanges();
			this.GroundWireRepairObject.AcceptChanges();
			this.BillableObject.AcceptChanges();
			this.KvObject.AcceptChanges();
			this.CircuitObject.AcceptChanges();
			this.ConductorTypeObject.AcceptChanges();
			this.ACSRObject.AcceptChanges();

			// updates the checksum original value
			CheckSumOriginal = CheckSum;
			RecurseVoidMethod(this, "AcceptChanges");
		}
		
		/// <summary>
		/// Makes <c>VendorDistributionPoleEntity</c> reject the last changes to its column property values by reverting to the values from a previous point in time.
		/// </summary>
		/// <remarks>
		/// <para>Sets <c>VendorDistributionPoleEntity</c>'s current values to either the original values from the database, if the <see cref="AcceptChanges()" />
		/// method has not been called since the Entity was first constructed, or to the last set of values saved 
		/// by the last call to <see cref="AcceptChanges()" />. It works by going through every one of <c>VendorDistributionPoleEntity</c>'s
		/// properties 
		/// and calling their <c>CancelChanges()</c> method. It also sets the Entity's <see cref="IsMarkedToDelete" /> property to <c>false</c>.</para>
		/// <para>For more information about how this works, see the documentation for the <see cref="ProjectCommon2.Helpers.PropertyHelper&lt;PropertyDataType&gt;" />
		/// class and the <see cref="AcceptChanges()" /> method.</para>
		/// </remarks>
		public void RejectChanges()
		{
			// set is IsMarkedToDelete to false & set current values to original
			IsMarkedToDelete = false;
			this.Vendor_Distribution_Poles_PoleIdObject.CancelChanges();
			this.MapFkObject.CancelChanges();
			this.SectionFkObject.CancelChanges();
			this.SpecieFkObject.CancelChanges();
			this.ClassFKObject.CancelChanges();
			this.LengthFkObject.CancelChanges();
			this.TreatmentFkObject.CancelChanges();
			this.LatitudeObject.CancelChanges();
			this.LongitudeObject.CancelChanges();
			this.InspByObject.CancelChanges();
			this.NumberObject.CancelChanges();
			this.AcquisitionDateObject.CancelChanges();
			this.YearObject.CancelChanges();
			this.LVisitObject.CancelChanges();
			this.D804Object.CancelChanges();
			this.DistributionTypeObject.CancelChanges();
			this.UserFkObject.CancelChanges();
			this.VendorFkObject.CancelChanges();
			this.InspectorFkObject.CancelChanges();
			this.ProjectFkObject.CancelChanges();
			this.Utility_Asset_Distributions_PoleFkObject.CancelChanges();
			this.GuardsQuantityObject.CancelChanges();
			this.PoleTagObject.CancelChanges();
			this.GroundWireRepairObject.CancelChanges();
			this.BillableObject.CancelChanges();
			this.KvObject.CancelChanges();
			this.CircuitObject.CancelChanges();
			this.ConductorTypeObject.CancelChanges();
			this.ACSRObject.CancelChanges();
			RecurseVoidMethod(this, "RejectChanges");
		}
		
		/// <summary>
		/// Creates a copy of the current <c>VendorDistributionPoleEntity</c> instance. Includes a copy of its Primary Key value by default.
		/// </summary>
		/// <remarks>
		/// No work performed here. Calls <see cref="Clone(bool)" /> with <paramref name="includeKeyField" /> set to <c>true</c>.
		/// </remarks>
		/// <returns>New instance of <c>VendorDistributionPoleEntity</c>.</returns>
		public PolePosition.v3.EntityLibrary.VendorDistributionPoleEntity Clone()
		{
			return Clone(true);
		}
		
		/// <summary>
		/// Creates a copy of the current <c>VendorDistributionPoleEntity</c> instance.
		/// </summary>
		/// <param name="includeKeyField">Specifies whether or not the Primary Key value is to be copied.</param>
		/// <remarks>
		/// Creates a new <c>VendorDistributionPoleEntity</c> by setting each of its properties equal to the corresponding property in the current
		/// <c>VendorDistributionPoleEntity</c> instance. However, it skips the property corresponding to the Primary Key if
		/// <paramref name="includeKeyField" /> is set to <c>false</c>.
		/// </remarks>
		/// <returns>New instance of <c>VendorDistributionPoleEntity</c>.</returns>
		public PolePosition.v3.EntityLibrary.VendorDistributionPoleEntity Clone(bool includeKeyField)
		{
			PolePosition.v3.EntityLibrary.VendorDistributionPoleEntity _c;
			_c = new PolePosition.v3.EntityLibrary.VendorDistributionPoleEntity(); //create new Entity object
					// CS: If we are at a column that is PK
						if (includeKeyField) 
						{
						
						_c.Vendor_Distribution_Poles_PoleIdObject.Value = this.Vendor_Distribution_Poles_PoleId;
					
						}
											
						_c.MapFkObject.Value = this.MapFk;
					
											
						_c.SectionFkObject.Value = this.SectionFk;
					
											
						_c.SpecieFkObject.Value = this.SpecieFk;
					
											
						_c.ClassFKObject.Value = this.ClassFK;
					
											
						_c.LengthFkObject.Value = this.LengthFk;
					
											
						_c.TreatmentFkObject.Value = this.TreatmentFk;
					
											
						_c.LatitudeObject.Value = this.Latitude;
					
											
						_c.LongitudeObject.Value = this.Longitude;
					
											
						_c.InspByObject.Value = this.InspBy;
					
											
						_c.NumberObject.Value = this.Number;
					
											
						_c.AcquisitionDateObject.Value = this.AcquisitionDate;
					
											
						_c.YearObject.Value = this.Year;
					
											
						_c.LVisitObject.Value = this.LVisit;
					
											
						_c.D804Object.Value = this.D804;
					
											
						_c.DistributionTypeObject.Value = this.DistributionType;
					
											
						_c.UserFkObject.Value = this.UserFk;
					
											
						_c.VendorFkObject.Value = this.VendorFk;
					
											
						_c.InspectorFkObject.Value = this.InspectorFk;
					
											
						_c.ProjectFkObject.Value = this.ProjectFk;
					
											
						_c.Utility_Asset_Distributions_PoleFkObject.Value = this.Utility_Asset_Distributions_PoleFk;
					
											
						_c.GuardsQuantityObject.Value = this.GuardsQuantity;
					
											
						_c.PoleTagObject.Value = this.PoleTag;
					
											
						_c.GroundWireRepairObject.Value = this.GroundWireRepair;
					
											
						_c.BillableObject.Value = this.Billable;
					
											
						_c.KvObject.Value = this.Kv;
					
											
						_c.CircuitObject.Value = this.Circuit;
					
											
						_c.ConductorTypeObject.Value = this.ConductorType;
					
											
						_c.ACSRObject.Value = this.ACSR;
					
			return _c;
		}
		
		/// <summary>
		/// Compares the given VendorDistributionPoleEntity object to the current VendorDistributionPoleEntity instance.
		/// </summary>
		/// <remarks>No work performed here. Calls <see cref="IsEqual(object, bool)" /> with <paramref name="compareIsDirtyOnly" />
		/// set to <c>false</c>.
		/// </remarks>
		/// <param name="entityToTest">Specifies the <c>VendorDistributionPoleEntity</c> instance to be tested.</param>
		/// <returns><c>true</c> if both instances are equal, <c>false</c> otherwise.</returns>
		public bool IsEqual(PolePosition.v3.EntityLibrary.VendorDistributionPoleEntity entityToTest)
		
		{
			return IsEqual(entityToTest, false);
		}

		/// <summary>
		/// Compares the given VendorDistributionPoleEntity object to the current VendorDistributionPoleEntity instance, 
		/// providing the option to test only those properties in the given Entity that have been modified.
		/// </summary>
		///
		/// <param name="entityToTest">Specifies the <c>VendorDistributionPoleEntity</c> instance to be tested.</param>
		/// <param name="compareIsDirtyOnly">Specifies that the comparison should be done on the given object's modified properties only.</param>
		///
		/// <returns><c>true</c> if both instances are equal, <c>false</c> otherwise.</returns>
		///
		/// <exception cref="System.InvalidCastException">Thrown if the given object is not of type VendorDistributionPoleEntity.
		/// The <c>throw</c> is performed by <see cref="ProjectCommon2.Helpers.ExceptionHelper.Throw(System.Exception)" />,
		/// which handles logging and other related activities.
		/// </exception>
		///
		/// <exception cref="ProjectCommon2.Exceptions.IsDirtyNotTrueException">
		/// Thrown if the given object has no modified properties to test for.
		/// </exception>
		/// <remarks>
		/// Compares every property in the two objects, except Checksum, after making sure that the given object is of the right type.
		/// If <paramref name="compareIsDirtyOnly" /> is set to <c>true</c>, only those properties in the given Entity that have changed
		/// since load (their <c>IsDirty</c> attribute is <c>true</c>) will be used in the comparison process.
		/// </remarks>
		public bool IsEqual(object entityToTest, bool compareIsDirtyOnly)
		{
			if (entityToTest.GetType() != this.GetType())
			{
				string msg = "Expected type {0}, but got type {1}";
				msg = string.Format(msg, this.GetType().ToString(), entityToTest.GetType().ToString());
				ProjectCommon2.Helpers.ExceptionHelper.Throw(new System.InvalidCastException(msg));

			}
			
			PolePosition.v3.EntityLibrary.VendorDistributionPoleEntity VendorDistributionPoleToTest = (PolePosition.v3.EntityLibrary.VendorDistributionPoleEntity)entityToTest; 
			
			//Cannot perform an isDirty comparison on an entity with no dirty properties
            if (!VendorDistributionPoleToTest.IsDirty == true & compareIsDirtyOnly)
            {
                throw new ProjectCommon2.Exceptions.IsDirtyNotTrueException("Cannot perform an IsDirty comparison on an VendorDistributionPoleEntity with no dirty properties");
            }
			
			// Vendor_Distribution_Poles_PoleId
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.Vendor_Distribution_Poles_PoleIdObject.Value, this.Vendor_Distribution_Poles_PoleIdObject.Value) && VendorDistributionPoleToTest.Vendor_Distribution_Poles_PoleIdObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.Vendor_Distribution_Poles_PoleIdObject.Value, this.Vendor_Distribution_Poles_PoleIdObject.Value))
				{return false;}
			}
			// MapFk
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.MapFkObject.Value, this.MapFkObject.Value) && VendorDistributionPoleToTest.MapFkObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.MapFkObject.Value, this.MapFkObject.Value))
				{return false;}
			}
			// SectionFk
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.SectionFkObject.Value, this.SectionFkObject.Value) && VendorDistributionPoleToTest.SectionFkObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.SectionFkObject.Value, this.SectionFkObject.Value))
				{return false;}
			}
			// SpecieFk
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.SpecieFkObject.Value, this.SpecieFkObject.Value) && VendorDistributionPoleToTest.SpecieFkObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.SpecieFkObject.Value, this.SpecieFkObject.Value))
				{return false;}
			}
			// ClassFK
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.ClassFKObject.Value, this.ClassFKObject.Value) && VendorDistributionPoleToTest.ClassFKObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.ClassFKObject.Value, this.ClassFKObject.Value))
				{return false;}
			}
			// LengthFk
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.LengthFkObject.Value, this.LengthFkObject.Value) && VendorDistributionPoleToTest.LengthFkObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.LengthFkObject.Value, this.LengthFkObject.Value))
				{return false;}
			}
			// TreatmentFk
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.TreatmentFkObject.Value, this.TreatmentFkObject.Value) && VendorDistributionPoleToTest.TreatmentFkObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.TreatmentFkObject.Value, this.TreatmentFkObject.Value))
				{return false;}
			}
			// Latitude
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.LatitudeObject.Value, this.LatitudeObject.Value) && VendorDistributionPoleToTest.LatitudeObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.LatitudeObject.Value, this.LatitudeObject.Value))
				{return false;}
			}
			// Longitude
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.LongitudeObject.Value, this.LongitudeObject.Value) && VendorDistributionPoleToTest.LongitudeObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.LongitudeObject.Value, this.LongitudeObject.Value))
				{return false;}
			}
			// InspBy
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.InspByObject.Value, this.InspByObject.Value) && VendorDistributionPoleToTest.InspByObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.InspByObject.Value, this.InspByObject.Value))
				{return false;}
			}
			// Number
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.NumberObject.Value, this.NumberObject.Value) && VendorDistributionPoleToTest.NumberObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.NumberObject.Value, this.NumberObject.Value))
				{return false;}
			}
			// AcquisitionDate
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.AcquisitionDateObject.Value, this.AcquisitionDateObject.Value) && VendorDistributionPoleToTest.AcquisitionDateObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.AcquisitionDateObject.Value, this.AcquisitionDateObject.Value))
				{return false;}
			}
			// Year
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.YearObject.Value, this.YearObject.Value) && VendorDistributionPoleToTest.YearObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.YearObject.Value, this.YearObject.Value))
				{return false;}
			}
			// LVisit
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.LVisitObject.Value, this.LVisitObject.Value) && VendorDistributionPoleToTest.LVisitObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.LVisitObject.Value, this.LVisitObject.Value))
				{return false;}
			}
			// D804
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.D804Object.Value, this.D804Object.Value) && VendorDistributionPoleToTest.D804Object.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.D804Object.Value, this.D804Object.Value))
				{return false;}
			}
			// DistributionType
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.DistributionTypeObject.Value, this.DistributionTypeObject.Value) && VendorDistributionPoleToTest.DistributionTypeObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.DistributionTypeObject.Value, this.DistributionTypeObject.Value))
				{return false;}
			}
			// UserFk
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.UserFkObject.Value, this.UserFkObject.Value) && VendorDistributionPoleToTest.UserFkObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.UserFkObject.Value, this.UserFkObject.Value))
				{return false;}
			}
			// VendorFk
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.VendorFkObject.Value, this.VendorFkObject.Value) && VendorDistributionPoleToTest.VendorFkObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.VendorFkObject.Value, this.VendorFkObject.Value))
				{return false;}
			}
			// InspectorFk
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.InspectorFkObject.Value, this.InspectorFkObject.Value) && VendorDistributionPoleToTest.InspectorFkObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.InspectorFkObject.Value, this.InspectorFkObject.Value))
				{return false;}
			}
			// ProjectFk
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.ProjectFkObject.Value, this.ProjectFkObject.Value) && VendorDistributionPoleToTest.ProjectFkObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.ProjectFkObject.Value, this.ProjectFkObject.Value))
				{return false;}
			}
			// Utility_Asset_Distributions_PoleFk
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.Utility_Asset_Distributions_PoleFkObject.Value, this.Utility_Asset_Distributions_PoleFkObject.Value) && VendorDistributionPoleToTest.Utility_Asset_Distributions_PoleFkObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.Utility_Asset_Distributions_PoleFkObject.Value, this.Utility_Asset_Distributions_PoleFkObject.Value))
				{return false;}
			}
			// GuardsQuantity
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.GuardsQuantityObject.Value, this.GuardsQuantityObject.Value) && VendorDistributionPoleToTest.GuardsQuantityObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.GuardsQuantityObject.Value, this.GuardsQuantityObject.Value))
				{return false;}
			}
			// PoleTag
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.PoleTagObject.Value, this.PoleTagObject.Value) && VendorDistributionPoleToTest.PoleTagObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.PoleTagObject.Value, this.PoleTagObject.Value))
				{return false;}
			}
			// GroundWireRepair
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.GroundWireRepairObject.Value, this.GroundWireRepairObject.Value) && VendorDistributionPoleToTest.GroundWireRepairObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.GroundWireRepairObject.Value, this.GroundWireRepairObject.Value))
				{return false;}
			}
			// Billable
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.BillableObject.Value, this.BillableObject.Value) && VendorDistributionPoleToTest.BillableObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.BillableObject.Value, this.BillableObject.Value))
				{return false;}
			}
			// Kv
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.KvObject.Value, this.KvObject.Value) && VendorDistributionPoleToTest.KvObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.KvObject.Value, this.KvObject.Value))
				{return false;}
			}
			// Circuit
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.CircuitObject.Value, this.CircuitObject.Value) && VendorDistributionPoleToTest.CircuitObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.CircuitObject.Value, this.CircuitObject.Value))
				{return false;}
			}
			// ConductorType
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.ConductorTypeObject.Value, this.ConductorTypeObject.Value) && VendorDistributionPoleToTest.ConductorTypeObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.ConductorTypeObject.Value, this.ConductorTypeObject.Value))
				{return false;}
			}
			// ACSR
			if (compareIsDirtyOnly)
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.ACSRObject.Value, this.ACSRObject.Value) && VendorDistributionPoleToTest.ACSRObject.IsDirty == true)
				{return false;}
			}
			else
			{
				if 	(!object.Equals(VendorDistributionPoleToTest.ACSRObject.Value, this.ACSRObject.Value))
				{return false;}
			}
			return true;
		}
		
		/// <summary>
		/// Returns a string that represents the current <c>VendorDistributionPoleEntity</c> object.
		/// </summary>
		/// <remarks>Takes the Primary Key property of <c>VendorDistributionPoleEntity</c> and converts it to a <c>string</c> using
		/// <see cref="System.Object.ToString()" />.
		/// </remarks>
		/// <returns>String conversion of <c>VendorDistributionPoleEntity's</c> Primary Key property.</returns>
		public override string ToString()
		{
			return this.Vendor_Distribution_Poles_PoleId.ToString();
		}

		/// <summary>
		/// Converts the current <c>VendorDistributionPoleEntity</c> object to an XML document.
		/// </summary>
		///
		/// <returns>
		/// <see cref="System.Xml.XmlDocument" /> object that represents the current <c>VendorDistributionPoleEntity</c>.
		/// </returns>
		///
		/// <remarks>
		/// Goes through everyone of <c>VendorDistributionPoleEntity</c>'s column properties, and creates an XML element from its name.
		/// Then, it inserts the property's value into its corresponding XML element, and adds it to the document.
		/// </remarks>
		public System.Xml.XmlDocument ToXml()
		{
			System.Xml.XmlDocument _XDoc = new System.Xml.XmlDocument(); //create new XML doc
			_XDoc.LoadXml("<VendorDistributionPole />");
			System.Xml.XmlElement _XElement; 
			
			// Vendor_Distribution_Poles_PoleId
			_XElement = _XDoc.CreateElement("Vendor_Distribution_Poles_PoleId");
			_XElement.InnerText = this.Vendor_Distribution_Poles_PoleId.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// MapFk
			_XElement = _XDoc.CreateElement("MapFk");
			_XElement.InnerText = this.MapFk.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// SectionFk
			_XElement = _XDoc.CreateElement("SectionFk");
			_XElement.InnerText = this.SectionFk.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// SpecieFk
			_XElement = _XDoc.CreateElement("SpecieFk");
			_XElement.InnerText = this.SpecieFk.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// ClassFK
			_XElement = _XDoc.CreateElement("ClassFK");
			_XElement.InnerText = this.ClassFK.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// LengthFk
			_XElement = _XDoc.CreateElement("LengthFk");
			_XElement.InnerText = this.LengthFk.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// TreatmentFk
			_XElement = _XDoc.CreateElement("TreatmentFk");
			_XElement.InnerText = this.TreatmentFk.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// Latitude
			_XElement = _XDoc.CreateElement("Latitude");
			_XElement.InnerText = this.Latitude.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// Longitude
			_XElement = _XDoc.CreateElement("Longitude");
			_XElement.InnerText = this.Longitude.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// InspBy
			_XElement = _XDoc.CreateElement("InspBy");
			_XElement.InnerText = this.InspBy.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// Number
			_XElement = _XDoc.CreateElement("Number");
			_XElement.InnerText = this.Number.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// AcquisitionDate
			_XElement = _XDoc.CreateElement("AcquisitionDate");
			_XElement.InnerText = this.AcquisitionDate.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// Year
			_XElement = _XDoc.CreateElement("Year");
			_XElement.InnerText = this.Year.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// LVisit
			_XElement = _XDoc.CreateElement("LVisit");
			_XElement.InnerText = this.LVisit.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// D804
			_XElement = _XDoc.CreateElement("D804");
			_XElement.InnerText = this.D804.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// DistributionType
			_XElement = _XDoc.CreateElement("DistributionType");
			_XElement.InnerText = this.DistributionType.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// UserFk
			_XElement = _XDoc.CreateElement("UserFk");
			_XElement.InnerText = this.UserFk.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// VendorFk
			_XElement = _XDoc.CreateElement("VendorFk");
			_XElement.InnerText = this.VendorFk.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// InspectorFk
			_XElement = _XDoc.CreateElement("InspectorFk");
			_XElement.InnerText = this.InspectorFk.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// ProjectFk
			_XElement = _XDoc.CreateElement("ProjectFk");
			_XElement.InnerText = this.ProjectFk.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// Utility_Asset_Distributions_PoleFk
			_XElement = _XDoc.CreateElement("Utility_Asset_Distributions_PoleFk");
			_XElement.InnerText = this.Utility_Asset_Distributions_PoleFk.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// GuardsQuantity
			_XElement = _XDoc.CreateElement("GuardsQuantity");
			_XElement.InnerText = this.GuardsQuantity.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// PoleTag
			_XElement = _XDoc.CreateElement("PoleTag");
			_XElement.InnerText = this.PoleTag.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// GroundWireRepair
			_XElement = _XDoc.CreateElement("GroundWireRepair");
			_XElement.InnerText = this.GroundWireRepair.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// Billable
			_XElement = _XDoc.CreateElement("Billable");
			_XElement.InnerText = this.Billable.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// Kv
			_XElement = _XDoc.CreateElement("Kv");
			_XElement.InnerText = this.Kv.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// Circuit
			_XElement = _XDoc.CreateElement("Circuit");
			_XElement.InnerText = this.Circuit.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// ConductorType
			_XElement = _XDoc.CreateElement("ConductorType");
			_XElement.InnerText = this.ConductorType.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			// ACSR
			_XElement = _XDoc.CreateElement("ACSR");
			_XElement.InnerText = this.ACSR.ToString();
			_XDoc.DocumentElement.AppendChild(_XElement);
			
			return _XDoc;
		}
		
        bool RecurseBooleanProperty(ICustomEntity entity, string propertyName)
        {
            /*
             * By: Jerry Nixon
             * On: November 13, 2007
             * To: Recurse all child entities (including lists) of a given boolean property 
             */

            // loop through entity properties

            foreach (System.Reflection.PropertyInfo _Property in entity.GetType().GetProperties())
            {
                // test for entity or entitylist types

                if (!typeof(ICustomEntity).IsAssignableFrom(_Property.PropertyType)
                    && !typeof(System.Collections.IEnumerable).IsAssignableFrom(_Property.PropertyType))
                    continue;

                // fetch value

                object _Value;
                _Value = _Property.GetValue(entity, null);

                // skip on null

                if (_Value == null)
                    continue;

                // process 

                System.Reflection.PropertyInfo _PropertyInfo;
                _PropertyInfo = _Property.PropertyType.GetProperty(propertyName);

                if (_PropertyInfo == null)
                    continue;

                if ((bool)_PropertyInfo.GetValue(_Value, null))
                    return true;
            }

            // finally return (false if void)

            return false;
        }

        void RecurseVoidMethod(ProjectCommon2.Interfaces.ICustomEntity entity, string methodName)
        {
            /*
             * By: Jerry Nixon
             * On: November 13, 2007
             * To: Recurse all child entities (including lists) of a given void method 
             */

            // loop through entity properties

            foreach (System.Reflection.PropertyInfo _Property in entity.GetType().GetProperties())
            {
                // test for entity or entitylist types

                if (!typeof(ICustomEntity).IsAssignableFrom(_Property.PropertyType) 
                    && !typeof(System.Collections.IEnumerable).IsAssignableFrom(_Property.PropertyType))
                    continue;

                // fetch value

                object _Value;
                _Value = _Property.GetValue(entity, null);

                // skip on null

                if (_Value == null)
                    continue;

                // process 
				System.Reflection.MemberInfo _MethodInfo = _Value.GetType().GetMethod(methodName);
				
				if(_MethodInfo == null)
					continue;

                _Property.PropertyType.InvokeMember(methodName,
                    System.Reflection.BindingFlags.InvokeMethod, null, _Value, null);
            }
        }

		#endregion
		
	}
}